package com.summer.shopping.domain.table;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

import lombok.Builder;
import lombok.Data;

/**
 * @TableName quan
 */
@TableName(value ="quan")
@Data
@Builder
public class Quan implements Serializable {
    @TableId
    private Long id;

    private String worth;

    private Long linkProdId;

    private LocalDateTime createTime;

    private String name;

    private String description;

    private static final long serialVersionUID = 1L;


    public static Quan getQuan(String name,String description,String worth,Long linkProdId){
        return Quan.builder()
                .name(name)
                .description(description)
                .worth(worth)
                .linkProdId(linkProdId)
                .createTime(LocalDateTime.now())
                .build();
    }

    public static Quan getUniversalQuan(String name,String description,String worth){
        return Quan.builder()
                .name(name)
                .description(description)
                .worth(worth)
                .linkProdId(0L)
                .createTime(LocalDateTime.now())
                .build();
    }



    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Quan other = (Quan) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getWorth() == null ? other.getWorth() == null : this.getWorth().equals(other.getWorth()))
            && (this.getLinkProdId() == null ? other.getLinkProdId() == null : this.getLinkProdId().equals(other.getLinkProdId()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
                && (this.getName() == null? other.getName() == null : this.getName().equals(other.getName()))
                && (this.getDescription() == null? other.getDescription() == null : this.getDescription().equals(other.getDescription()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getWorth() == null) ? 0 : getWorth().hashCode());
        result = prime * result + ((getLinkProdId() == null) ? 0 : getLinkProdId().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getName() == null)? 0 : getName().hashCode());
        result = prime * result + ((getDescription() == null)? 0 : getDescription().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", worth=").append(worth);
        sb.append(", linkProdId=").append(linkProdId);
        sb.append(", createTime=").append(createTime);
        sb.append(", name=").append(name);
        sb.append(", description=").append(description);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}